<style>
    .form-copy {
        margin-right: 5px;
        border-radius: 0;
        box-shadow: none;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.42857143;
        color: #555;
        border: 1px solid #ccc;
        transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    }
    .select2 {
        margin-right: 5px
    }
</style>
{{-- 行选操作 start --}}
<input type="checkbox" class="grid-select-all" />&nbsp;
<div class="btn-group">
    <a class="btn btn-sm btn-default">  {{ trans('admin.action') }}</a>
    <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown">
        <span class="caret"></span>
        <span class="sr-only">Toggle Dropdown</span>
    </button>
    <ul class="dropdown-menu" role="menu" style="position: absolute;z-index: 10000;min-width: 80px;">
        <li><a href="#" class="grid-batch-0">删除</a></li>
    </ul>
</div>
{{-- 行选操作 end --}}
<div class="btn-group" style="margin-right: 10px">
    <form class="form-inline" action="{{ $action }}" pjax-container method="get">
        <select id="type" name="type">
            {{ $filtersBlade['type'] }}
        </select>
        <select id="tag" name="tag">
            {{ $filtersBlade['tag'] }}
        </select>
        <div class="input-group">
            <button style="margin-left: 10px;" class="btn btn-sm btn-info submit"><i class="fa fa-search"></i>&nbsp;&nbsp;{{ trans('admin.search') }}</button>
            <a style="margin-left: 10px;" href="{{ $action }}" class="btn btn-sm btn-default"><i class="fa fa-undo"></i>&nbsp;&nbsp;{{ trans('admin.reset') }}</a>
        </div>
    </form>
</div>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $('#type').select2({placeholder: '类型', allowClear: true, width: '120px'});
        $('#tag').select2({placeholder: '标签', allowClear: true, width: '120px'});

        $('.grid-select-all').iCheck({checkboxClass:'icheckbox_minimal-blue'});
        $('.grid-select-all').on('ifChanged', function(event) {
            if (this.checked) {
                $('.grid-row-checkbox').iCheck('check');
            } else {
                $('.grid-row-checkbox').iCheck('uncheck');
            }
        });

        var selectedRows = function () {
            var selected = [];
            $('.grid-row-checkbox:checked').each(function(){
                selected.push($(this).data('id'));
            });
            return selected;
        };

        $('.grid-batch-0').on('click', function() {
            var idArr = selectedRows();
            if(idArr.length == 0){
                swal('请选择删除内容', '', 'error');
                return false;
            }
            var id = idArr.join();
            swal({
                title: "确认删除?",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确认",
                showLoaderOnConfirm: true,
                cancelButtonText: "取消",
                preConfirm: function() {
                    return new Promise(function(resolve) {
                        $.ajax({
                            method: 'post',
                            url: '/xqc/quality/tag/' + id,
                            data: {
                                _method:'delete',
                                _token:"{{ csrf_token() }}",
                            },
                            success: function (data) {
                                $.pjax.reload('#pjax-container');
                                resolve(data);
                            }
                        });
                    });
                }
            }).then(function(result) {
                var data = result.value;
                if (typeof data === 'object') {
                    if (data.status) {
                        toastr.success(data.message);
                    } else {
                        swal(data.message, '', 'error');
                    }
                }
            });
        });
    });
</script>
